package com.android.jay.wzp_voice.view.login.manager;

import com.android.jay.wzp_voice.model.user.User;

/**
 * Created by wzp on 2020/1/6 0006.
 * <p>
 * 描述  ：单例管理登录用户信息
 */
public class UserManager {

    private static UserManager mInstance;
    private User mUser;

    public static UserManager getInstance() {
        //双检查机制 单例模式
        if (mInstance == null) {
            synchronized (UserManager.class) {
                if (mInstance == null) {
                    mInstance = new UserManager();
                }
            }
        }
        return mInstance;
    }

    /**
     * 保存用户信息到内存
     **/
    public void saveUser(User user) {
        mUser = user;
        saveLocal(user);
    }

    /**
     * 保存到数据库中
     **/
    private void saveLocal(User user) {
    }

    /**
     * 获取用户信息
     **/
    public User getUser() {
        return mUser;
    }

    public User getLocalUser() {
        return null;
    }


    /**
     * 判断是否登录
     **/
    public boolean hsaLogin() {
        return getUser() == null ? false : true;
    }

    /**
     *
     * **/

    public void removeUser(){
        mUser = null;
        removeLocal();
    }


    private void removeLocal(){

    }






}
